﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Windows.Forms;
using System.Drawing;

namespace ALDIOrganizer
{
    public partial class Cell
    {
        [NonSerialized]
        private Sheet _parent;
        public Sheet GetParent
        {
            get
            {
                return _parent;
            }
        }
        
        public SheetType GetParentMode
        {
            get
            {
                return GetParent.Mode;
            }
        }
        
        public Template GetParentAsTemplate
        {
            get
            {
                if (GetParentMode != SheetType.Template)
                {
                    Debugger.Break(); // this shouldn't happen!                    
                }
                return GetParent as Template;                
            }
        }

        public Rota GetParentAsRota
        {
            get
            {
                if (GetParentMode != SheetType.Rota)
                {
                    Debugger.Break(); // this should not happen                    
                }
                return GetParent as Rota;                
            }
        }

        internal protected void SetParent(Sheet pRefill)
        {
            _parent = pRefill;
        }

        private WorkingHoursSpan GetParentWorkingHours
        {
            get
            {
                if (GetParentMode == SheetType.Template)
                {
                    return GetParentAsTemplate.WorkingHours[_column - 1];
                }
                // Parent is in SheetType.Rota
                return GetParentAsRota.GetWorkingHours[_column - 1];
            }
        }




    }
}
